{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "234f48d0",
   "metadata": {},
   "source": [
    "# VTA 环境配置"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "fb4e018f",
   "metadata": {
    "tags": [
     "remove-cell"
    ]
   },
   "outputs": [],
   "source": [
    "import set_env"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9d5d049d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import vta\n",
    "\n",
    "\n",
    "env = vta.get_env()\n",
    "mock = env.mock\n",
    "assert mock.alu == \"skip_alu\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7e9d66e6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31mType:\u001b[39m        property\n",
      "\u001b[31mString form:\u001b[39m <property object at 0x7fbe8ff4f650>\n",
      "\u001b[31mSource:\u001b[39m     \n",
      "\u001b[38;5;66;03m# env.mock.fget\u001b[39;00m\n",
      "@property\n",
      "\u001b[38;5;28;01mdef\u001b[39;00m mock(self):\n",
      "    \u001b[33m\"\"\"A mock version of the Environment\u001b[39m\n",
      "\n",
      "\u001b[33m    The ALU, dma_copy and intrinsics will be\u001b[39m\n",
      "\u001b[33m    mocked to be nop.\u001b[39m\n",
      "\u001b[33m    \"\"\"\u001b[39m\n",
      "    \u001b[38;5;28;01mif\u001b[39;00m self.mock_mode:\n",
      "        \u001b[38;5;28;01mreturn\u001b[39;00m self\n",
      "    \u001b[38;5;28;01mif\u001b[39;00m self._mock_env \u001b[38;5;28;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
      "        self._mock_env = copy.copy(self)\n",
      "        self._mock_env._dev_ctx = \u001b[38;5;28;01mNone\u001b[39;00m\n",
      "        self._mock_env.mock_mode = \u001b[38;5;28;01mTrue\u001b[39;00m\n",
      "    \u001b[38;5;28;01mreturn\u001b[39;00m self._mock_env"
     ]
    }
   ],
   "source": [
    "env.mock??"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "cc67cfbc",
   "metadata": {},
   "outputs": [],
   "source": [
    "cfg = env.cfg_dict\n",
    "cfg[\"TARGET\"] = \"xyz\"\n",
    "with vta.Environment(cfg):\n",
    "    assert vta.get_env().TARGET == \"xyz\"\n",
    "assert vta.get_env().TARGET == env.TARGET"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "81056053",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "xin",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
